{extend name="tplLayui/baseLayui" /}
{block name="headTitle"}数据管理系统{/block}
{block name="head"}
<!-- <script src="{$Think.config.config.admin}../js/jquery.min.js"></script> -->
<link rel="stylesheet" href="{$Think.config.config.layui}lib/extend/formSelects-v4.css" />
<script type="text/javascript"></script>
<style type="text/css">
</style>
{/block}
{block name="content"}
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>项目名成：</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-filter="name" lay-verify="required|name" autocomplete="off" placeholder="请输入项目名称" class="layui-input" value="{$info.name ?? ''}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">描述：</label>
                <div class="layui-input-block">
                    <textarea name="describe" placeholder="请输入描述" class="layui-textarea">{$info.describe ?? ''}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-lg" lay-submit lay-filter="btn_submit"> 保 存 </button>
                    <button class="layui-btn layui-btn-lg layui-btn-primary"> 重 置 </button>
                </div>
            </div>
            <input type="hidden" name="id" id="id" value="{$info.id ?? 0}" />
        </form>
    </div>

</div>
{/block}

{block name="tpljs"}

<script>
    var depart_id = '{$info.depart_id ?? 0}';
    layui.extend({
        index: 'lib/index',
    }).use(['index','form'],function(){
        var form  = layui.form,
        $     = layui.jquery,
        admin = layui.admin,
        layer = layui.layer;
        m = {
            init:function() {
                form.verify({
                    command: function(value, item){ //value：表单的值、item：表单的DOM对象
                        if(!new RegExp("^((http|https):\/\/.*)|[-=\sa-zA-Z0-9_\x80-\xff]+$").test(value)){
                            return '命令中格式不合法';
                        }
                    }
                    ,timerule: [
                        /^[-0-9,\*\/]+\s[-0-9,\*\/]+\s[-0-9,\*\/]+\s[-0-9,\*\/]+\s[-0-9,\*\/]+$/
                        ,'执行频率格式不正确，必须为：分|时|日|月|周'
                    ] 
                    ,logfile: [
                        /^[a-zA-Z0-9_]+$/
                        ,'文件名不带后缀，且仅包含字母数字下划线'
                    ] 
                });
                form.on('submit(btn_submit)', function (data) {
                    wm.load();
                    admin.req({
                        url:'/task_load/saveProject',
                        method:'post',
                        data:data.field,
                        success: function (res) {
                            wm.loaded();
                            if (res.code == 0) {
                                layer.alert(res.msg, {icon: 1, title:'提示'},function(index) {
                                    layer.close(index);
                                    parent.window.wm.closeTop();
                                    parent.layui.main.reload();
                                });
                            } else {
                                layer.alert(res.msg, {icon: 3, title:'提示'},function(index) {
                                    layer.close(index);
                                });
                            }
                        },
                        //done: function(res) {
                        //return false;
                        //},
                        error: function (res) {
                            wm.loaded();
                            layer.alert(res.msg, {icon: 3, title:'提示'});
                            return false;
                        }
                    });
                    return false;
                });
            }
        };
        m.init();
    })
</script>
{/block}

